<template>
  {{cValue}}
</template>
<script setup lang="ts">
import { PropType, computed, onMounted, ref, watch } from 'vue';
import { MTableColumnType } from '../../Table/types';
import { useDictStore } from '/@/store/modules/dict';
const dictStore = useDictStore()
const props = defineProps({
  data: {
    // 当前行数据
    type: Object
  },
  column: {
    // 列定义
    type: Object as PropType<MTableColumnType>
  }
})
const getCode = computed(()=>{
  return props.column?.componentProps?.code
})
// 字典数据
const dictData = ref([])
// 请求
const requestData =() =>{
  dictStore.requestData(getCode.value)
}

const cValue = computed(()=>{
  let v = props.data?.text
  dictData.value = dictStore.getDictData(getCode.value)
  dictData.value?.forEach((item: any)=>{
    if(item.value == v) {
      v = item.label
    }
  })
  return v
})
onMounted(()=>{
  requestData()
})
</script>
<style lang="less" scoped>

</style>